<template>
  <div class="member-order-detail" v-if="order">
    <!-- 头部 -->
    <OrderDetailAction :order="order"></OrderDetailAction>
    <!-- 进度 -->
    <DeatilStep :order="order"></DeatilStep>
    <!-- 物流 -->
    <Suspense>
      <template #default>
        <DetailLogistics
          v-if="[3, 4, 5].includes(order.orderState)"
          :order="order"
        ></DetailLogistics>
      </template>
      <template #fallback>
        <div class="loading">...loading</div>
      </template>
    </Suspense>

    <!-- 信息 -->
    <OrderInfo :order="order"></OrderInfo>
  </div>
</template>

<script>
import OrderDetailAction from './components/detail-action.vue'
import DeatilStep from './components/detail-step.vue'
import DetailLogistics from './components/detail-logistics.vue'
import OrderInfo from './components/detail-info.vue'
import { ref } from 'vue'
import { findOrderDetail } from '@/api/order'
import { useRoute } from 'vue-router'
export default {
  name: 'MemberDetail',
  components: { OrderDetailAction, DeatilStep, DetailLogistics, OrderInfo },
  setup () {
    const order = ref(null)
    const route = useRoute()
    findOrderDetail(route.params.id).then(data => {
      // console.log(order)
      order.value = data.result
    })
    return { order }
  }
}
</script>
<style  scoped lang="less">
.member-order-detail {
  background-color: #fff;
  height: 100%;
  .loading {
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 30px;
    background-color: #f5f5f5;
    margin: 30px 50px 0;
  }
}
</style>
